import java.util.Objects;

public class Point {
    private double x;
    private double y;

    // 构造方法
    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    // 访问方法
    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    // 覆盖toString()方法
    @Override
    public String toString() {
        return "Point[" + "x=" + x + ", y=" + y + ']';
    }

    // 覆盖equals()方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Point point = (Point) o;
        return Double.compare(point.x, x) == 0 &&
                Double.compare(point.y, y) == 0;
    }

    // 覆盖hashCode()方法
    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }

    // main()方法测试
    public static void main(String[] args) {
        // 创建测试点对象
        Point p1 = new Point(3.5, 4.5);
        Point p2 = new Point(3.5, 4.5);
        Point p3 = new Point(5.0, 6.0);

        // 测试toString()方法
        System.out.println("p1的toString(): " + p1);
        System.out.println("p2的toString(): " + p2);
        System.out.println("p3的toString(): " + p3);

        // 测试equals()方法
        System.out.println("p1 equals p2: " + p1.equals(p2));
        System.out.println("p1 equals p3: " + p1.equals(p3));
        System.out.println("p1 equals null: " + p1.equals(null));
        System.out.println("p1 equals 字符串: " + p1.equals("test"));

        // 测试hashCode()方法
        System.out.println("p1的hashCode: " + p1.hashCode());
        System.out.println("p2的hashCode: " + p2.hashCode());
        System.out.println("p3的hashCode: " + p3.hashCode());
    }
}